import { Controller, Get, Post, Body, Param, Delete, Query, Put } from '@nestjs/common';
import { Role_Service } from './role.service';
import { Role_CreateDto, Role_UpdateDto } from './assets/role.dto';
import { Role_FindDto } from './assets/role.dto';
import { ApiExtraModels, ApiTags } from '@nestjs/swagger';
import { util_ApiResponse_Base } from '@/common/util/apiResponse';
import { util_Index_ReturnContent } from '@/common/util/index';
import { Class_Index_ListAll } from '@/common/classes/index';

@Controller('/adm/role')
@ApiTags('role 角色')
export class Role_Controller {
  constructor(private readonly role_Service: Role_Service) {}

  @Post('/add')
  @util_ApiResponse_Base({
    dataType: 'dataType_add',
    //apiKey: '/adm/role/add Post',
  })
  async role_Create(@Body() body: Role_CreateDto) {
    return util_Index_ReturnContent(await this.role_Service.role_Create(body));
  }

  @Get('/listSelect')
  @ApiExtraModels(Class_Index_ListAll)
  @util_ApiResponse_Base({
    dataType: 'dataType_listSelect',
    //apiKey: '/adm/role/listSelect Get',
    type: Class_Index_ListAll,
  })
  async role_FindAllSelect() {
    return await util_Index_ReturnContent(await this.role_Service.role_FindAllSelect());
  }

  @Get('/list')
  @util_ApiResponse_Base({
    dataType: 'dataType_list',
    //apiKey: '/adm/role/list Get',
  })
  async role_FindByPage(@Query() query: Role_FindDto) {
    return util_Index_ReturnContent(await this.role_Service.role_FindByPage(query));
  }

  @Put('/update')
  @util_ApiResponse_Base({
    dataType: 'dataType_update',
    //apiKey: '/adm/role/update Put',
  })
  async role_Update(@Body() body: Role_UpdateDto) {
    return util_Index_ReturnContent(await this.role_Service.role_Update(body));
  }

  @Delete('/delete/:id')
  @util_ApiResponse_Base({
    dataType: 'dataType_delete',
    //apiKey: '/adm/role/delete/:id Delete',
  })
  async role_Remove(@Param('id') id: number) {
    return util_Index_ReturnContent(await this.role_Service.role_Remove(id));
  }
}
